(function(ns) {

	var OpenWinSceneMyGua = ns.OpenWinSceneMyGua = Hilo.Class.create({
		Extends: Hilo.Container,
		constructor: function(properties) {
			OpenWinSceneMyGua.superclass.constructor.call(this, properties);
			
			this.init(properties);

		},
		font:'36px arial',
		content:'我的西瓜',
		xglist:null,
		init: function(properties) {
			let that = this
			var bigbox = new Hilo.Bitmap({
				id: 'bigbox',
				x:this.width * .5,
				y:this.height * .4,
				image: properties.image[0],
				rect: [0, 0, 600, 576]
			});
			var g1 = new Hilo.Graphics({
				width: this.width,
				height: this.height,
				x: 0,
				y: 0,
				background: "#8B8B8B",
				alpha: .5
			});
			var text = new Hilo.Text({
				id:"text",
			    font: this.font,
			    text: this.content,
			    lineSpacing: 1,
				color:"#AA6812"
				//background:"#000000"
			})
			
			// var toShow = new Hilo.Text({
			// 	id:"toshow",
			//     font: this.font,
			//     text: "确定",
			// 	x:this.width * .5,
			//     lineSpacing: 1,
			// 	color:"#FFFFFF"
			// 	//background:"#FFFFFF"
			// })
			
			var btn2 = new Hilo.Bitmap({
				id: 'btn2',
				x:this.width * .5,
				y:this.height * .4,
				image: properties.image[1],
				rect: [0, 0, 240, 53]
			});
			
			// var cha = new Hilo.Bitmap({
			// 	id: 'cha',
			// 	x:this.width * .5,
			// 	y:this.height *.4,
			// 	image: properties.image[2],
			// 	rect: [0, 0, 51, 51]
			// });
			
			let viewguacontent = '<div class="xglist">'
				
				viewguacontent += '</div>'
			var elemgua = new Hilo.DOMElement({
				id:"elemgua",
			    element: Hilo.createElement('div', {innerHTML: viewguacontent,style: {position: 'relative',font: "34px",margin:"0 auto",top:"15px"}}),
				
				width: 250,height: 100,x: 0,y: 0,
			})
			//文字
			// let content="    "+"恭喜您获得XX西瓜一个，请前往购物车查看，下单后可随单领取(^=00=^)"
			// var mainelem = new Hilo.Text({
			// 	id:"mainelem",
			//     font: "30px arial",
			//     text: content,
			// 	lineSpacing: 5,
			// 	textVAlign:"middle",
			// 	color:"#ffffff",
			// 	// background:"#ffffff"
			// })
			
			g1.lineStyle(1, "#000000").beginFill("#000000").drawRect(0, 0, this.width, this.height).endFill().addTo(this);
			bigbox.pivotX = bigbox.width *.5
			bigbox.pivotY = bigbox.height *.5
			
			text.setFont("32px bolder")
			
			// console.log(text.textWidth)
			// console.log(mainelem)
				
			this.addChild(bigbox,text,btn2,elemgua);
			postAjax2({
			    id: 2,
			    method: "watermelon_mywatermelonlist",
			    params: {
			        "authKey": window.game.authKey,
			        "activityId": 41,
					"pageIndex":1,
					"pageSize":999
			    }
			}, function (datas) {
			    console.log(JSON.stringify(datas))
				if(!utilsClass.isEmpty(datas))
				that.xglist = datas
			});
		},

		show: function(score, bestScore) {
			this.visible = true;
			$("#elemgua").show();
			
			
			// this.getChildById('elem').pivotX = this.getChildById('elem').width * .5
			// this.getChildById('elem').pivotY = this.getChildById('elem').height * .5
			this.getChildById('elemgua').width =  this.getChildById('bigbox').width* .9 /2-10
			this.getChildById('elemgua').height = this.getChildById('bigbox').height* .6 /2.3

			// this.getChildById('elem').width =  this.getChildById('bigbox').width* .9 /2
			// this.getChildById('elem').height = this.getChildById('bigbox').height* .6 /2
			// mainelem.height = bigbox.height* .65
			
			// this.getChildById('elem').x = this.getChildById('bigbox').x/2 
			// this.getChildById('elem').y = this.getChildById('bigbox').y/4 
			this.getChildById('elemgua').x = (this.getChildById('bigbox').x - this.getChildById('bigbox').width * .45)* .5-5
			this.getChildById('elemgua').y = this.getChildById('bigbox').y * .32
			
			this.getChildById('btn2').pivotX = this.getChildById('btn2').width * .5
			this.getChildById('btn2').pivotY = this.getChildById('btn2').height * .5
			this.getChildById('btn2').y = this.getChildById('bigbox').y + this.getChildById('bigbox').height * .33
			// this.getChildById('toshow').pivotX = this.getChildById('btn2').width * .15
			// this.getChildById('toshow').pivotY = this.getChildById('btn2').height * .15
			// this.getChildById('toshow').y = this.getChildById('bigbox').y + this.getChildById('bigbox').height * .313
			
			// this.getChildById('cha').pivotX = this.getChildById('cha').width *.5
			// this.getChildById('cha').pivotY = this.getChildById('cha').height *.5
			// this.getChildById('cha').y= this.getChildById('bigbox').y + this.getChildById('bigbox').height * .5+50
			let viewguacontent = ''
			this.xglist.forEach((item,index)=>{
				viewguacontent += '<div class="xgitem">'
				viewguacontent += '<div class="xgitem_left">'
				viewguacontent += '<img src="'+item.thumbImg+'" class="itemIcon"/>'
				viewguacontent +="</div>"
				viewguacontent += '<div class="xgitem_center">'
				viewguacontent += item.prizeName
				viewguacontent +="</div>"
				viewguacontent += '<div class="xgitem_right" style="color:'+item.colorCode+';font-weight: bold;">'
				viewguacontent += item.statusStr
				viewguacontent +="</div>"
				viewguacontent +="</div>"
			})
			setTimeout(()=>{
				if(!utilsClass.isEmpty(this.xglist) && this.xglist.length>0)
				$("#elemgua .xglist").html(viewguacontent)
				else
				$("#elemgua .xglist").html("<div class='nomore'>暂无更多数据</div>")
				this.getChildById('text').x = this.getChildById('bigbox').x - this.getChildById('text').textWidth* .5
				this.getChildById('text').y = this.getChildById('bigbox').y - this.getChildById('bigbox').height* .49
			},15)
			
			
			
			
			// this.getChildById('score').setText(score);
			// this.getChildById('best').setText(bestScore);
			// this.getChildById('mask').alpha = 1;

			// Hilo.Tween.to(this.getChildById('gameover'), {alpha:1}, {duration:100});
			// Hilo.Tween.to(this.getChildById('board'), {alpha:1, y:this.getChildById('board').y-150}, {duration:200, delay:200});
			// Hilo.Tween.to(this.getChildById('score'), {alpha:1, y:this.getChildById('score').y-150}, {duration:200, delay:200});
			// Hilo.Tween.to(this.getChildById('best'), {alpha:1, y:this.getChildById('best').y-150}, {duration:200, delay:200});
			// Hilo.Tween.to(this.getChildById('start'), {alpha:1}, {duration:100, delay:600});
			// Hilo.Tween.to(this.getChildById('grade'), {alpha:1}, {duration:100, delay:600});
			// Hilo.Tween.to(this.getChildById('mask'), {alpha:0}, {duration:400});
			//点击
			// this.getChildById('toshow').on(Hilo.event.POINTER_START, function(e) {
			//     e.stopImmediatePropagation && e.stopImmediatePropagation();
			//     this.hide();
			// }.bind(this));
			this.getChildById('btn2').on(Hilo.event.POINTER_START, function(e) {
			    e.stopImmediatePropagation && e.stopImmediatePropagation();
			    this.hide();
			}.bind(this));
			
			// this.getChildById('cha').on(Hilo.event.POINTER_START, function(e) {
			//     e.stopImmediatePropagation && e.stopImmediatePropagation();
			// 	//console.log(this)
			// 	// window.location.reload();
				
			//     this.hide();
			// }.bind(this));
			
			
		},
		getReady(){
			this.visible = false
			
		},

		hide: function() {
			this.visible = false;
			//document.getElementById("elem").display = "none"
			$("#elemgua").hide();
		}
	});

})(window.game);
